//
//  Displayer.m
//  SujetObserver
//
//  Created by Thomas Dupont on 05/01/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Displayer.h"
#import "SensorData.h"

@implementation Displayer

#pragma mark -
#pragma mark Memory Management
- (void)awakeFromNib
{
	displayVersion = NO;
}

- (void)dealloc
{	
	[dataValue release];
	dataValue = nil;
	
	[dataVersion release];
	dataVersion = nil;
	
	[super dealloc];
}

#pragma mark -
#pragma mark Accessors
@synthesize displayVersion;
- (void)setDisplayVersion:(BOOL)boolVersion
{
	displayVersion = boolVersion;
	if (displayVersion) {
		[dataVersion setHidden:NO];
	}
	else {
		[dataVersion setHidden:YES];
	}

}

#pragma mark -
#pragma mark Observing Implementation
- (void)observeValueForKeyPath:(NSString *)keyPath
					  ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context
{
	SensorData* newData = (SensorData*)[change objectForKey:NSKeyValueChangeNewKey];
	[dataValue setStringValue:[NSString stringWithFormat:@"Value:%d",[newData data]]];
	if (displayVersion) {
		[dataVersion setStringValue:[NSString stringWithFormat:@"Version:%d",[newData dataVersion]]];
	}
}

@end
